#include <iostream>
#include "Cube.h"


Cube::Cube(int r,int g,int b,vec3 pos, float size) : object()
{
    this->r = r;
    this->g = g;
    this->b = b;
    this->pos.x = pos.x;
    this->pos.y = pos.y;
    this->pos.z = pos.z;
    this->size = size;
}

void    Cube::draw()
{
    glBegin(GL_QUADS);
   // std::cout << "cube en x y z  size: " << " " << pos.x << " " << pos.y << " " << pos.z << size << std::endl;

    glColor3ub(r,g,b);
    glVertex3d(pos.x + size / 2.0,pos.y + size / 2.0,pos.z + size / 2.0);
    glVertex3d(pos.x + size / 2.0,pos.y + size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y + size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y + size / 2.0,pos.z + size / 2.0);

    //glColor3ub(0,255,0);
    glVertex3d(pos.x + size / 2.0,pos.y - size / 2.0,pos.z + size / 2.0);
    glVertex3d(pos.x + size / 2.0,pos.y - size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x + size / 2.0,pos.y + size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x + size / 2.0,pos.y + size / 2.0,pos.z + size / 2.0);

    //glColor3ub(0,0,255);
    glVertex3d(pos.x - size / 2.0,pos.y - size / 2.0,pos.z + size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y - size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x + size / 2.0,pos.y - size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x + size / 2.0,pos.y - size / 2.0,pos.z + size / 2.0);

    //glColor3ub(255,255,0);
    glVertex3d(pos.x - size / 2.0,pos.y + size / 2.0,pos.z + size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y + size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y - size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y - size / 2.0,pos.z + size / 2.0);

    //glColor3ub(0,255,255);
    glVertex3d(pos.x + size / 2.0,pos.y + size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x + size / 2.0,pos.y - size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y - size / 2.0,pos.z - size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y + size / 2.0,pos.z - size / 2.0);

    //glColor3ub(255,0,255);
    glVertex3d(pos.x + size / 2.0,pos.y - size / 2.0,pos.z + size / 2.0);
    glVertex3d(pos.x + size / 2.0,pos.y + size / 2.0,pos.z + size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y + size / 2.0,pos.z + size / 2.0);
    glVertex3d(pos.x - size / 2.0,pos.y - size / 2.0,pos.z + size / 2.0);


    glEnd();
}

Cube::~Cube()
{
    //dtor
}
